-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API maps #413
API maps #413
Conversation
View Playwright Report (note: open the "playwright-report" artifact) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is amazing, I didn't even know typescript could do type-level operations that are this complicated. 😅 It can be in a later PR, but I think some comments in api-map.d.ts would be useful for future reader trying to understand what is going on in there. I don't think it needs to be detailed, just a basic explanation of what it's trying to achieve.
This is a first step towards making serialized API interfaces more type safe, as mentioned in #391.
This has some TypeScript black magic in it, but it basically amounts to describing all APIs on a TypeScript type and then using some common mapping types. For now, this is only set up to work for
Offscreen
, but should be able to be expanded upon.It ensures type safety in the
ApiMapInit
type, which is used to initialize API maps. This pattern was already seen throughout the application, but with more lenient type checks, and mistakes could still be made.